<%= form_with(model: blog, local: true) do |form| %>
  <% if blog.errors.any? %>
    <% blog.errors.full_messages.each do |error| %>
      <%= alert_generator error %>
    <% end %>
  <% end %>

  <div class="form-group">
    <%= form.label :title %>
    <%= form.text_field :title, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :topic_id %>
    <%= form.collection_select(:topic_id, Topic.all, :id, :title, 
                                  {
                                    include_blank: true
                                  },class: "form-control") 
                                  %>
  </div>

  <div class="form-group">
    <%= form.radio_button :status, 'draft' %>
    <%= form.label :status, 'Draft' %>

    <%= form.radio_button :status, 'published' %>
    <%= form.label :status, 'Published' %>
  </div>

  <div class="custom-file">
    <input type="file" class="custom-file-input" id=<%= form.file_field :main_image %>
    <label class="custom-file-label" for="validatedCustomFile">Upload a main image file...</label>
  </div>
  
  <div class="form-group">
    <%= form.label :body %>
    <%= form.text_area :body, class: "form-control", rows: "20" %>
  </div>

  <div class="form-group">
    <%= form.submit "Submit", class: "btn btn-primary" %>
  </div>
<% end %>
